package zhh.tangbao.commodity.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import zhh.tangbao.commodity.entity.CommodityMachineStockData;
import zhh.tangbao.commodity.vo.StockDataVo;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *     描述
 * </p>
 * @author 粥灰灰
 * <p>2023/4/19</p>
 */

@Mapper
public interface CommodityMachineStockDataDao extends BaseMapper<CommodityMachineStockData> {
    int insertBatchSomeColumn(Collection<CommodityMachineStockData> stocks);

    @Select("SELECT e.commodity_name,e.commodity_price,sd.* " +
            "FROM commodity_entity e " +
            "JOIN commodity_machine_stock s ON e.id = s.commodity_entity_id AND e.data_status = 1 " +
            "JOIN commodity_machine_stock_data sd ON s.id = sd.stock_id " +
            "WHERE s.machine_id = #{machineId} ")
    List<StockDataVo> listStockDataVo(@Param("machineId") String machineId);
}
